{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "using DifferentialEquations\n",
    "using PyPlot\n",
    "using ReactionMechanismSimulator"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "phaseDict = readinput(\"../src/testing/superminimal.rms\") #load mechanism dictionary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "spcs = phaseDict[\"gas\"][\"Species\"]; #mechanism dictionaries index:  phaseDict[phasename][\"Species\" or \"Reactions\"]\n",
    "rxns = phaseDict[\"gas\"][\"Reactions\"];"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "ig = IdealGas(spcs,rxns,name=\"gas\"); #Define the phase (how species thermodynamic and kinetic properties calculated)\n",
    "#Tfcn(x::Float64) = 1000.0+10.0*x\n",
    "#Pfcn(x::Float64) = 1e5\n",
    "#initialconds = Dict([\"T\"=>Tfcn,\"P\"=>Pfcn,\"H2\"=>0.67,\"O2\"=>0.33]); #Set simulation Initial Temp and Pressure\n",
    "initialconds = Dict([\"T\"=>[1000.0,1100.0,1200.0,1300.0,1400.0],\"ts\"=>[0.0,20.0,50.0,100.0,140.0],\"P\"=>[1.0e5,1.0e5,1.0e5,1.0e5,1.0e5],\"H2\"=>0.67,\"O2\"=>0.33]); #Set simulation Initial Temp and Pressure\n",
    "domain,y0 = ParametrizedTPDomain(phase=ig,initialconds=initialconds); #Define the domain (encodes how system thermodynamic properties calculated)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "react = Reactor(domain,y0,(0.0,150.1)); #Create the reactor object"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "sol = solve(react.ode,DifferentialEquations.CVODE_BDF(),abstol=1e-20,reltol=1e-12); #solve the ode associated with the reactor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bsol = Simulation(sol,domain);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plotmolefractions(bsol,150.0; t0=1e-15, N=1000, tol=0.01)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plotrops(bsol,\"OH\",tol=0.01)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "@webio": {
   "lastCommId": "8cd25b334afb4fad8a5e694f67c89798",
   "lastKernelId": "33c6aacc-e57e-4c26-a2fb-af1087567e09"
  },
  "kernelspec": {
   "display_name": "Julia 1.1.0",
   "language": "julia",
   "name": "julia-1.1"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "1.1.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
